const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => {
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `${i}`,
            code: `code${i}`,
            name: `name${i}`,
            programName: `programName${i}`,
            important: 1,
            noticeTime: '2019-11-20T06:36:44.206Z',
            noticerName: 'noticerName',
            status: 1,
            rowVersion: 'string',
            options: ['update', 'release', 'cancel', 'signfor', 'abandon']
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});

router.get('/:id', (req, res) => {
    const {id} = req.params;
    res.json(
        {
            message: 'string',
            payload: {
                id: '1',
                code: `code${id}`,
                name: `name${id}`,
                programId: `programId${id}`,
                programCode: `programCode${id}`,
                programName: `programName${id}`,
                important: 1,
                isNeedReply: true,
                content: `content${id}`,
                rowVersion: 'A11111111',
                options: ['update', 'release', 'cancel', 'signfor', 'abandon'],
                details: [
                    {
                        id: 'id1',
                        dealerId: 'dealerId1',
                        dealerCode: 'dealerCode1',
                        dealerName: 'dealerName1',
                        isSigned: false,
                        signedTime: '2019-11-21T01:19:14.660Z',
                        isReplied: true,
                        repiiedTime: '2019-11-21T01:19:14.660Z',
                        replyContent: 'replyContent1',
                        attachments: [
                            {
                                fileId: 'fileId2',
                                fileName: 'fileName2'
                            }
                        ]
                    }
                ],
                attachments: [
                    {
                        fileId: 'fileId1',
                        fileName: 'fileName1'
                    }
                ]
            }
        }
    );
});

router.post('/', (req, res) => {
    res.json(
        {
            message: '新增成功'
        }
    );
});

router.put('/:id', (req, res) => {
    res.json(
        {
            message: '修改成功'
        }
    );
});

router.put('/:id/release', (req, res) => {
    res.json(
        {
            message: '发布成功'
        }
    );
});

router.put('/:id/cancel', (req, res) => {
    res.json(
        {
            message: '取消发布成功'
        }
    );
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废成功'
    });
});

router.put('/:id/signfor', (req, res) => {
    res.json(
        {
            message: '签收成功'
        }
    );
});

router.put('/:id/reply', (req, res) => {
    res.json(
        {
            message: '回复成功'
        }
    );
});

module.exports = router;
